package com.bc.trade.util;

public class Strings {

	public static boolean isNullOrEmpty(Object str) {
		return str == null || str.toString().equals("");
	}
	
	public static String toString(Throwable e) {
		StringBuffer stack = new StringBuffer();
		stack.append(e);
		stack.append("\r\n");

		Throwable rootCause = e.getCause();

		while (rootCause != null) {
			stack.append("Root Cause:\r\n");
			stack.append(rootCause);
			stack.append("\r\n");
			stack.append(rootCause.getMessage());
			stack.append("\r\n");
			stack.append("StackTrace:\r\n");
			stack.append(rootCause);
			stack.append("\r\n");
			rootCause = rootCause.getCause();
		}


		for (int i = 0; i < e.getStackTrace().length; i++) {
			stack.append(e.getStackTrace()[i].toString());
			stack.append("\r\n");
		}
		return stack.toString();
	}
}
